using System;
using System.Collections;
using System.Collections.Generic;
using MyFrame.Mono;
using Platform.Skill.Deployer;
using UnityEngine;

namespace GardeningSkeleton.Platform.SkillSpace
{
    public class PierceImpact : BaseImpactEffect
    {
        ParabolicSkillDeployer deployer;

        public override void EndEffect()
        {
            deployer.ReturnSword();
        }

        public override void Execute(SkillDeployer baseDeployer)
        {
            deployer = (ThrowSwordSkillDeployer)baseDeployer;
            // MonoMgr.Instance.AddUpdateEvent(PierceUpdate);
        }

        public override void OnImpactTriggerEntry(Collider2D other)
        {
            deployer.AttackStart(other);
            if (skillData.pierced < skillData.pierceCount && other.gameObject.layer == LayerMask.NameToLayer("Enemy"))
            {
                skillData.pierced++;
                return;
            }
            skillData.pierced = 0;

            deployer.StopRigidbody();
            deployer.transform.parent = other.transform;
        }

        private void PierceUpdate()
        {

        }
    }
}